<template>
    <rm-layout-left splitcolor="#F8F8FF" movingcolor="#00ff00" :splitwidth="0" :fixsize="0" :minfixsize="80" :canDrag="false">
        <rm-layout-top splitcolor="#F8F8FF" :splitwidth="5" :fixsize="55">
            <template v-slot:fix>
                <div style="height: 55px; border: 1px solid #ccc">
                    <div style="width: 100%; margin-top: 8px">
                        <div style="width: 60%; float: left">
                            <table style="font-size: 14px; width: 100%; border-spacing: 0px" class="table1style" border="0">
                                <tr>
                                    <td width="80" align="right" style="font-size: 17px; font-weight: bold">条码号 ：</td>
                                    <td>
                                        <el-input v-model="txtbarcode" clearable placeholder="请扫描条码号" @keyup.enter.native="scanBarcode" style="width: 100%" size="medium" ref="barcode" id="barcodediv" @focus="BarCodeSelect" :readonly="readonly"></el-input>
                                    </td>
                                    <td>执行科室：{{ exedeptname }}</td>
                                    <td width="100" align="right">默认退回原因:</td>
                                    <td>
                                        <el-autocomplete class="inline-input" v-model.trim="txtrejReason" :fetch-suggestions="querySearch" placeholder="请输入内容" style="width: 200px" clearable></el-autocomplete>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div style="width: 40%; float: left">
                            <table style="float: right" class="top-deal">
                                <tr>
                                    <td>
                                        <el-button icon="el-icon-document" @click="btnSave()" :disabled="isused">保存</el-button>
                                    </td>
                                    <td>
                                        <el-button icon="el-icon-printer" @click="btnPrint($event)">打印</el-button>
                                    </td>
                                    <td>
                                        <el-button icon="el-icon-close" @click="btnClear()">清除</el-button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </template>
            <rm-layout-right splitcolor="#F8F8FF" movingcolor="#0000ff" :splitwidth="5" :fixsize="400">
                <template v-slot:fix>
                    <div style="height: 100%" v-if="isshow">
                        <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="410">
                            <template v-slot:fix>
                                <div ref="xTable2Div" style="height: 100%;" >
                                    <vxe-table show-overflow border ref="xTable2" height="auto" row-id="id" size="mini" :select-config="{ reserve: true }" :data.sync="detail" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                                        <vxe-table-column field="seq" title="序号 " width="50" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="req_itemname" title="申请项目名称 " width="166" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="item_price" title="实际价格 " width="88" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="qty" title="数量 " width="57" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="amount" title="金额 " width="57" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="req_itemcode" title="申请项目代码 " width="119" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="his_itemcode" title="HIS原始项目代码 " width="131" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="his_recordid" title="HIS中对应记录号 " width="129" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="combitemna" title="所属组合项目简称 " width="127" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="base_price" title="理论/区域价格 " width="104" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="stat_flag" title="统计标志 " width="79" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="other_flag" title="其它标志 " width="79" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="status" title="状态 " width="58" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="lab_add" title="实验室添加标志 " width="113" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="add_dt" title="添加时间 " width="92" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                                        <vxe-table-column field="add_user" title="添加用户 " width="97" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="req_groupid" title="分单类别ID " width="97" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="charge_flag" title="计价标志 " width="82" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="his_refcol1" title="HIS表相关字段1 " width="137" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="his_refcol2" title="HIS表相关字段2 " width="137" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="his_refcol3" title="HIS表相关字段3 " width="137" header-align="center"></vxe-table-column>
                                        <vxe-table-column field="reportid" title="报告ID " width="80" header-align="center"></vxe-table-column>
                                    </vxe-table>
                                </div>
                            </template>
                            <div style="height: 100%; width: 100%;">
                                <el-carousel trigger="click" style="height: 100%; width: 100%;" height="100%" :autoplay="false">
                                    <el-carousel-item v-for="(item,i) in LPicData" :key="i">
                                        <div style="position:relative; height: 100%; width: 100%;">
                                            <el-button style="z-index:1000; float: right; position: absolute; top: 80%; right: 8%;" type="danger" @click="deletepic(item)" icon="el-icon-delete" circle></el-button>
                                            <el-image :src="item" @click="onPreview(item)" style=" width: 100%; height: 99%;"></el-image>
                                        </div>
                                    </el-carousel-item>
                                </el-carousel>
                            </div>
                        </rm-layout-top>
                    </div>
                    <div style="height: 100%" v-if="!isshow">
                        <div ref="xTable2Div" style="height: 100%">
                            <vxe-table show-overflow border ref="xTable2" height="auto" row-id="id" size="mini" :select-config="{ reserve: true }" :data.sync="detail" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                                <vxe-table-column field="seq" title="序号 " width="50" header-align="center"></vxe-table-column>
                                <vxe-table-column field="req_itemname" title="申请项目名称 " width="166" header-align="center"></vxe-table-column>
                                <vxe-table-column field="item_price" title="实际价格 " width="88" header-align="center"></vxe-table-column>
                                <vxe-table-column field="qty" title="数量 " width="57" header-align="center"></vxe-table-column>
                                <vxe-table-column field="amount" title="金额 " width="57" header-align="center"></vxe-table-column>
                                <vxe-table-column field="req_itemcode" title="申请项目代码 " width="119" header-align="center"></vxe-table-column>
                                <vxe-table-column field="his_itemcode" title="HIS原始项目代码 " width="131" header-align="center"></vxe-table-column>
                                <vxe-table-column field="his_recordid" title="HIS中对应记录号 " width="129" header-align="center"></vxe-table-column>
                                <vxe-table-column field="combitemna" title="所属组合项目简称 " width="127" header-align="center"></vxe-table-column>
                                <vxe-table-column field="base_price" title="理论/区域价格 " width="104" header-align="center"></vxe-table-column>
                                <vxe-table-column field="stat_flag" title="统计标志 " width="79" header-align="center"></vxe-table-column>
                                <vxe-table-column field="other_flag" title="其它标志 " width="79" header-align="center"></vxe-table-column>
                                <vxe-table-column field="status" title="状态 " width="58" header-align="center"></vxe-table-column>
                                <vxe-table-column field="lab_add" title="实验室添加标志 " width="113" header-align="center"></vxe-table-column>
                                <vxe-table-column field="add_dt" title="添加时间 " width="92" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                                <vxe-table-column field="add_user" title="添加用户 " width="97" header-align="center"></vxe-table-column>
                                <vxe-table-column field="req_groupid" title="分单类别ID " width="97" header-align="center"></vxe-table-column>
                                <vxe-table-column field="charge_flag" title="计价标志 " width="82" header-align="center"></vxe-table-column>
                                <vxe-table-column field="his_refcol1" title="HIS表相关字段1 " width="137" header-align="center"></vxe-table-column>
                                <vxe-table-column field="his_refcol2" title="HIS表相关字段2 " width="137" header-align="center"></vxe-table-column>
                                <vxe-table-column field="his_refcol3" title="HIS表相关字段3 " width="137" header-align="center"></vxe-table-column>
                                <vxe-table-column field="reportid" title="报告ID " width="80" header-align="center"></vxe-table-column>
                            </vxe-table>
                        </div>
                    </div>
                </template>
                <div style="height: 100%; width: 100%; background-color: #ddccbb">
                    <div ref="xTableDiv" style="height: 100%">
                        <vxe-table
                            show-overflow
                            ref="xTable1"
                            height="auto"
                            row-id="id"
                            :select-config="{
                                reserve: true,
                                checkMethod: checkMethod,
                            }"
                            :keyboard-config="keyConfig"
                            :keyboard-local-config="keyLocalConfig"
                            :data.sync="master"
                            border
                            size="mini"
                            show-header-overflow
                            highlight-current-row
                            highlight-hover-row
                            resizable
                            stripe
                            @current-change="detailretrieve"
                            :edit-config="{
                                trigger: 'click',
                                mode: 'cell',
                                showStatus: true,
                                activeMethod: CellActive,
                                showIcon: false,
                            }"
                            @edit-closed="EditCloseEvent"
                            @cell-dblclick="CellDBLClickEvent"
                        >
                            <vxe-table-column type="selection" width="40" :edit-render="{ name: 'selection' }" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="reject_reason" title="退回原因" width="150" header-align="center" align="center" :edit-render="{ name: 'select', options: RejectiReasonOption,events: { change: selChange }}">
                                <template v-slot:header="{ column }">
                                    <span style="color: blue">退回原因</span>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="description" title="备注 " width="167" header-align="center" :edit-render="{ name: 'input', autoselect: true }">
                                <template v-slot:header="{ column }">
                                    <span style="color: blue">备注</span>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="tellman" title="临床通知人 " width="117" header-align="center" :edit-render="{ name: 'input', autoselect: true }" v-show="rejectreqmusttell == '1'">
                                <template v-slot:header="{ column }">
                                    <span style="color: blue">临床通知人</span>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="photoimage" title="拍照" width="40px" align="center" v-if="isshow">
                                <template v-slot="{ row }">
                                    <i class="el-icon-camera" v-show="mustPhotoStr.indexOf('\'' + row.reject_reason + '\'') > -1" style="color: red; padding: 5px 10px !important" @click="cameraEvent(row)"></i>
                                    <i class="el-icon-camera" v-show="mustPhotoStr.indexOf('\'' + row.reject_reason + '\'') <= -1 " style="color: padding: 5px 10px !important" @click="cameraEvent(row)"></i>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="req_groupna" title="分单类别" width="100" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_deptname" title="申请科室" width="84" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_wardname" title="病人病区" width="85" header-align="center"></vxe-table-column>
                            <vxe-table-column field="telnum" title="病区电话" width="90" header-align="center"></vxe-table-column>
                            <!--病区电话待改视图后修改，暂定取值wardtelnum,具体名称为视图修改后的名称-->
                            <vxe-table-column field="req_bedno" title="病人床号" width="74" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="pat_name" title="病人姓名" width="74" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_sexname" title="性别" width="48" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="req_statname" title="申请状态" width="72" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_groupid" title="分单类别ID" width="100" header-align="center"></vxe-table-column>
                            <vxe-table-column field="barcode" title="条码号" width="127" header-align="center"></vxe-table-column>
                            <vxe-table-column field="emer_flag" title="加急" width="60" header-align="center">
                                <template v-slot="{ row }">
                                    <div style="color: red">
                                        {{ row.emer_flag == "1" ? "急" : "" }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="sample_items" title="项目描述" width="203" header-align="center"></vxe-table-column>
                            <!-- <vxe-table-column field="reject_reason" title="退回原因 " width="65" header-align="center"></vxe-table-column> -->
                            <vxe-table-column field="base_amount" title="基准总金额" width="85" header-align="center" align="right"></vxe-table-column>
                            <vxe-table-column field="pat_no" title="病人号 " width="105" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_docname" title="申请医生" width="95" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_typename" title="病人类型" width="97" header-align="center"></vxe-table-column>
                            <vxe-table-column field="create_dt" title="条码生成时间" width="130" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="create_username" title="条码生成用户" width="104" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_username" title="退回用户" width="90" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_dt" title="退回时间" width="128" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="print_dt" title="打印日期" width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="print_username" title="打印用户" width="91" header-align="center"></vxe-table-column>
                            <vxe-table-column field="print_count" title="打印次数" width="78" header-align="center" align="right"></vxe-table-column>
                            <vxe-table-column field="sampled_dt" title="采样时间" width="121" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="sampled_username" title="采样用户" width="93" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_dt" title="申请日期" width="125" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="pat_diag" title="临床诊断" width="133" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_agestr" title="年龄字串" width="88" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_id" title="病人唯一号" width="137" header-align="center"></vxe-table-column>
                            <vxe-table-column field="inp_date" title="入院日期" width="123" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="send_dt" title="护工交接时间" width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="send_username" title="送出护工" width="93" header-align="center"></vxe-table-column>
                            <vxe-table-column field="recieve_dt" title="检验科接收时间" width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="recieve_username" title="检验科接收用户" width="153" header-align="center"></vxe-table-column>
                            <vxe-table-column field="charge_dt" title="计价时间" width="125" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="charge_username" title="计价人" width="104" header-align="center"></vxe-table-column>
                            <vxe-table-column field="amount" title="实收总金额" width="120" header-align="center" align="right"></vxe-table-column>
                            <vxe-table-column
                                field="charge_flag"
                                title="收费标志"
                                width="73"
                                header-align="center"
                                :edit-render="{
                                    name: 'select',
                                    options: $opt.chargeOption,
                                }"
                            ></vxe-table-column>
                            <vxe-table-column field="test_dt" title="上机时间" width="129" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="test_username" title="上机用户" width="106" header-align="center"></vxe-table-column>
                            <vxe-table-column field="report_dt" title="报告时间" width="134" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="report_username" title="检验医生姓名" width="102" header-align="center"></vxe-table-column>
                            <vxe-table-column field="rechk_username" title="核对医生姓名" width="95" header-align="center"></vxe-table-column>
                            <vxe-table-column field="alter_flag" title="警告标志" width="82" header-align="center"></vxe-table-column>
                            <vxe-table-column field="saleman" title="所属销售人" width="93" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_cardno" title="就诊卡号" width="129" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_comm" title="医生备注" width="197" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_birth" title="病人生日" width="90" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="pat_ageyear" title="年龄岁数" width="100" header-align="center"></vxe-table-column>
                            <vxe-table-column field="inp_id" title="住院标识" width="116" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_diag_icd" title="诊断的ICD10编码" width="161" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_address" title="病人联系地址" width="195" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_nation" title="国家/民族" width="104" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_idcardno" title="身份证号护照号" width="192" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_phone" title="联系电话" width="174" header-align="center"></vxe-table-column>
                            <vxe-table-column field="charge_typename" title="收费类型" width="102" header-align="center"></vxe-table-column>
                            <vxe-table-column field="perform_deptname" title="执行科室" width="103" header-align="center"></vxe-table-column>
                            <vxe-table-column field="original_reqno" title="原始单号" width="150" header-align="center"></vxe-table-column>
                            <vxe-table-column field="secrecy" title="加密标志" width="97" header-align="center"></vxe-table-column>
                            <vxe-table-column field="other_stat" title="备用标志" width="96" header-align="center"></vxe-table-column>
                            <vxe-table-column field="cancel_dt" title="作废时间" width="125" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="cancel_username" title="作废用户" width="105" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_count" title="退回次数" width="100" header-align="center" align="right"></vxe-table-column>
                            <vxe-table-column field="specimen_code" title="标本类型" width="104" header-align="center"></vxe-table-column>
                            <vxe-table-column field="sample_detail" title="标本备注说明" width="131" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_reason" title="送检目的" width="137" header-align="center"></vxe-table-column>
                            <vxe-table-column field="multi_seq" title="多条码序号" width="100" header-align="center"></vxe-table-column>
                            <vxe-table-column field="report_id" title="报告单ID" width="91" header-align="center"></vxe-table-column>
                            <vxe-table-column field="report_user" title="检验医生" width="101" header-align="center"></vxe-table-column>
                            <vxe-table-column field="rechk_user" title="核对医生" width="110" header-align="center"></vxe-table-column>
                            <vxe-table-column field="recieve1_dt" title="工作组接收时间" width="129" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="recieve1_username" title="工作组接收用户" width="129" header-align="center"></vxe-table-column>
                            <vxe-table-column field="inlib_status" title="入库状态" width="112" header-align="center"></vxe-table-column>
                            <vxe-table-column field="library_id" title="所在库位ID" width="112" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reqtype" title="业务类别" width="118" header-align="center">
                                <template v-slot="{ row }">
                                    <div>
                                        {{ row.reqtype == "C" ? "检验" : row.reqtype == "H" ? "输血" : "" }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="pat_height" title="身高" width="80" header-align="center"></vxe-table-column>
                            <vxe-table-column field="weight" title="体重" width="80" header-align="center"></vxe-table-column>
                            <vxe-table-column field="abo_bldtype" title="ABO血型" width="90" header-align="center"></vxe-table-column>
                            <vxe-table-column field="rh_bldtype" title="RH血型" width="90" header-align="center"></vxe-table-column>
                            <vxe-table-column field="hospcodename" title="送检医院" width="133" header-align="center"></vxe-table-column>
                            <vxe-table-column field="recieve_host" title="检验科接收电脑" width="175" header-align="center"></vxe-table-column>
                            <vxe-table-column field="rcvmsg" title="签收消息" width="125" header-align="center"></vxe-table-column>

                            <vxe-table-column field="req_deptno" title="申请科室" width="114" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_wardno" title="病人病区" width="115" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_sex" title="性别" width="68" header-align="center">
                                <template v-slot="{ row }">
                                    <div>
                                        {{ row.reqtype == "1" ? "男" : row.reqtype == "2" ? "女" : "未知" }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="req_stat" title="申请状态" width="102" header-align="center"></vxe-table-column>
                            <vxe-table-column field="req_docno" title="申请医生" width="105" header-align="center"></vxe-table-column>
                            <vxe-table-column field="pat_typecode" title="病人类型" width="97" header-align="center"></vxe-table-column>
                            <vxe-table-column field="create_user" title="条码生成用户" width="114" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_user" title="退回用户" width="110" header-align="center"></vxe-table-column>
                            <vxe-table-column field="print_user" title="打印用户" width="101" header-align="center"></vxe-table-column>
                            <vxe-table-column field="sampled_user" title="采样用户" width="93" header-align="center"></vxe-table-column>
                            <vxe-table-column field="send_user" title="送出护工" width="93" header-align="center"></vxe-table-column>
                            <vxe-table-column field="recieve_user" title="检验科接收用户" width="133" header-align="center"></vxe-table-column>
                            <vxe-table-column field="charge_user" title="计价人" width="94" header-align="center"></vxe-table-column>
                            <vxe-table-column field="test_user" title="上机用户" width="106" header-align="center"></vxe-table-column>
                            <vxe-table-column field="charge_typeno" title="收费类型" width="112" header-align="center"></vxe-table-column>
                            <vxe-table-column field="perform_dept" title="执行科室" width="113" header-align="center"></vxe-table-column>
                            <vxe-table-column field="cancel_user" title="作废用户" width="115" header-align="center"></vxe-table-column>
                            <vxe-table-column field="report_user" title="检验医生" width="111" header-align="center"></vxe-table-column>
                            <vxe-table-column field="rechk_user" title="核对医生" width="110" header-align="center"></vxe-table-column>
                            <vxe-table-column field="recieve1_user" title="工作组接收用户" width="149" header-align="center"></vxe-table-column>
                            <vxe-table-column field="hospcode" title="送检医院" width="153" header-align="center"></vxe-table-column>
                        </vxe-table>
                    </div>
                </div>
            </rm-layout-right>
        </rm-layout-top>
        <!--（-1弹窗）-->
        <el-dialog title="退回提示" :visible.sync="rejeoptips" v-el-drag-dialog :close-on-click-modal="false" width="45%" :destroy-on-close="true">
            <div>
                <div style="over-flow: auto">
                    <h3 style="color: red">{{ msg }}</h3>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button icon="el-icon-circle-check" ref="btnfocus2" @click="rejeoptips = false" :autofocus="true">确定</el-button>
            </div>
        </el-dialog>

        <!--（-99弹窗）-->
        <el-dialog title="标本退回时删除报告信息" :visible.sync="rejeopdialog" v-el-drag-dialog :close-on-click-modal="false" width="45%" :destroy-on-close="true">
            <div style="over-flow: auto">
                <div style="color: red" v-html="msg"></div>
            </div>

            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogclose('1')" ref="btnfocus3" @keyup.right.native="chkbtnfun('btnfocus3')" v-if="rejeopdialogflag.indexOf('删除并退回') > -1">删除并退回</el-button>

                <el-button @click="dialogclose('0')" ref="btnfocus4" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus4')" v-if="rejeopdialogflag.indexOf('仅退回') > -1">仅退回</el-button>

                <el-button @click="dialogclose('0')" ref="btnfocus5" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus5')" v-if="rejeopdialogflag.indexOf('提示是否退回') > -1">退回</el-button>

                <el-button @click="dialogclose('1')" ref="btnfocus6" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus6')" v-if="rejeopdialogflag.indexOf('退回并删除未审核') > -1">退回并删除未审核</el-button>

                <el-button @click="canceldialog()" ref="btnfocus7" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus7')" v-if="rejeopdialogflag.indexOf('取消') > -1">取消</el-button>

                <el-button @click="rejeopdialog = false" ref="btnfocus8" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus8')" v-if="rejeopdialogflag.indexOf('禁止退回标本') > -1">确定</el-button>

                <el-button @click="dialogclose('2')" ref="btnfocus9" :autofocus="true" @keyup.left.native="chkbtnfun('btnfocus9')" v-if="rejeopdialogflag.indexOf('退回并修改条码号') > -1">退回并修改条码号</el-button>
            </div>
        </el-dialog>
        <!--(保存返回失败条码信息弹窗)-->
        <el-dialog title="标本退回时删除报告信息" :visible.sync="rejeopdialogRet" v-el-drag-dialog :close-on-click-modal="false" width="50%" :destroy-on-close="true">
            <div v-for="msg in msglist" :key="msg.title" style="over-flow: auto">
                <h3 style="color: red">{{ msg }}</h3>
            </div>

            <div slot="footer" class="dialog-footer">
                <el-button icon="el-icon-circle-check" @click="rejeopdialogRet = false" ref="btnfocus9" :autofocus="true">确定</el-button>
            </div>
        </el-dialog>
        <!--(踢回标本时开窗选择分单类别)扫描条码信息弹窗-->
        <el-dialog title="申请项目信息" :visible.sync="dialogReqItem" v-el-drag-dialog :close-on-click-modal="false" width="1000px" :destroy-on-close="true" ref="refdialogReqItem">
            <div style="height: 400px; over-flow: auto">
                <rm-layout-right splitcolor="white" movingcolor="#0000ff" :splitwidth="5" :fixsize="730">
                    <template v-slot:fix>
                        <vxe-table
                            :data.sync="groupdetaillist"
                            :loading="loading"
                            :keyboard-config="keyConfig"
                            :select-config="selectConfig"
                            :sort-config="{ trigger: 'cell' }"
                            :edit-config="{
                                trigger: 'click',
                                mode: 'cell',
                                showStatus: true,
                                showIcon: false,
                            }"
                            border
                            fit
                            height="auto"
                            header-align="center"
                            highlight-current-row
                            highlight-hover-row
                            class="mytablestyle"
                            highlight-hover-column
                            ref="xTable"
                            resizable
                            show-header-overflow="tooltip"
                            show-overflow="tooltip"
                            size="mini"
                            stripe
                        >
                            <vxe-table-column field="req_itemname" title="项目名称" width="130"> </vxe-table-column>
                            <vxe-table-column field="item_price" title="单价" width="70" header-align="center" align="right"> </vxe-table-column>
                            <vxe-table-column field="req_itemcode" title="项目代码" width="80"> </vxe-table-column>
                            <vxe-table-column field="his_itemcode" title="项目代码(HIS)" width="100"> </vxe-table-column>
                            <vxe-table-column field="his_itemname" title="项目名称(HIS)" width="120"> </vxe-table-column>
                            <vxe-table-column field="perform_dept" title="执行科室" width="80"> </vxe-table-column>
                            <vxe-table-column field="inputcode" title="拼音码" width="80"> </vxe-table-column>
                            <vxe-table-column field="req_groupid" title="分单类别ID" width="80"> </vxe-table-column>
                        </vxe-table>
                    </template>
                    <div style="height: 100%; width: 100%; background-color: #ddccbb">
                        <vxe-table
                            :data.sync="grouplist"
                            :loading="loading"
                            :keyboard-config="keyConfig"
                            :select-config="selectConfig"
                            :sort-config="{ trigger: 'cell' }"
                            :edit-config="{
                                trigger: 'click',
                                mode: 'cell',
                                showStatus: true,
                                showIcon: false,
                            }"
                            @current-change="groupListChangeEvent"
                            border
                            fit
                            height="auto"
                            header-align="center"
                            highlight-current-row
                            highlight-hover-row
                            class="mytablestyle"
                            highlight-hover-column
                            ref="refgrouplist"
                            resizable
                            show-header-overflow="tooltip"
                            show-overflow="tooltip"
                            size="mini"
                            stripe
                        >
                            <vxe-table-column field="chkreqgroup" width="50" align="center">
                                <template v-slot="{ row }">
                                    <el-checkbox v-model="row.chkreqgroup" true-label="1" false-label="0" @change="chkreqgroupChange(row)"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="req_groupid" title="分单类别" width="100" :formatter="formatFun"> </vxe-table-column>
                            <vxe-table-column field="samplecnt" title="数量" width="70"> </vxe-table-column>
                        </vxe-table>
                    </div>
                </rm-layout-right>
            </div>

            <div slot="footer" class="dialog-footer">
                <el-button icon="el-icon-circle-check" @click="diagPromise_click(1)">确定</el-button>
                <el-button icon="el-icon-close" @click="diagPromise_click(0)" :autofocus="true">取消</el-button>
            </div>
        </el-dialog>
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择电话通知人" :visible.sync="dialogusersel">
            <rm-pop-common ref="popcom" @change="diagUserInfoChange" @cancel="dialogusersel = false" datatype="userinfo"></rm-pop-common>
            <!-- 登陆界面 -->
        </el-dialog>
                <el-dialog title="退回提示" :visible.sync="rejeopshowdialog" v-el-drag-dialog :close-on-click-modal="false" width="45%" :destroy-on-close="true">
            <div>
                <div style="over-flow: auto">
                    <div style="color: red" v-html="showrejmsg"></div>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button icon="el-icon-circle-check" ref="btnfocus2" @click="showdialogclose(1)" :autofocus="true">确定</el-button>
                <el-button icon="el-icon-circle-check" ref="btnfocus2" @click="showdialogclose(0)" :autofocus="true">取消</el-button>
            </div>
        </el-dialog>
        <!-- <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示:请重新输入" :visible.sync="dialogLoginVisible" width="30%">
            <div class="el-message-box__status el-icon-warning"></div>
            <div class="el-message-box__message" style="padding-top: 24px">
                <div>
                    <span>工号：</span>
                    <el-input v-model="loginuserno" clearable placeholder="工号" style="width: 100%" size="medium" ref="loginuserno"></el-input>
                    <span>密码：</span>
                    <el-input v-model="loginpwd" clearable placeholder="密码" style="width: 100%" size="medium" ref="loginpwd"></el-input>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="CommitTips()">确 定</el-button>
                <el-button @click="CancelTips()">取 消</el-button>
            </span>
        </el-dialog> -->
        <el-image-viewer v-if="showViewer" :on-close="closeViewer" :url-list="viewerList"/>
    </rm-layout-left>
</template>

<script type="text/javascript">
import md5 from "js-md5";
import ElImageViewer from '../../../../element-ui/packages/image/src/image-viewer';
export default {
components: { ElImageViewer },
    name: "LIS213",
    data() {
        return {
            showViewer: false,
            viewerList: [],
            txtbarcode: "",
            rejectcheckedsample: "",
            rejectreqmusttell: "",
            rejectreasonnoedit: "",
            rejectdeletereport: "",
            reject_photo: "",
            master: [],
            detail: [],
            exedeptname: "",
            okFirstLoading: true,
            tempindex: 0,
            chkenterflag: "",
            rejeoptips: false,
            rejeopdialog: false,
            rejeopdialogflag: "",
            rejeopdialogRet: false,
            readonly: false,
            dialogReqItem: false,
            keyConfig: {
                isDel: true,
                isTab: true,
                isEdit: true,
            },
            keyLocalConfig: {
                isArrow: true,
            },
            selectConfig: { tigger: "row" },
            msglist: [],
            msg: "",
            flag: "",
            lastmaster: [],
            lastdetail: [],
            rejectinfo: [],
            RejectiReasonOption: [],
            userno: this.$tool.getSession(this.$tool.loginuserno),
            ReqBackstyleid: "",
            loading: false,
            grouplistdetail: [],
            groupdetaillist: [],
            req_grouplist: [],
            dialogusersel: false,
            currentRow: [],
            islogin: false,
            loginuserno: "",
            loginpwd: "",
            camerarowindex: "",
            LPicData: [],
            isshow: false,
            txtrejReason: "",
            isused: false,
            msglist:[],
            rejeopshowdialog:false,
            showrejmsg:"",
            retinfo:"",
            mustPhotoStr: "",
        };
    },
    watch: {
        rejeoptips(val) {
            if (val) {
                this.readonly = true;
            } else {
                this.readonly = false;
            }
        },
        rejeopdialog(val) {
            if (val) {
                this.readonly = true;
            } else {
                this.readonly = false;
            }
        },
        rejeopdialogRet(val) {
            if (val) {
                this.readonly = true;
            } else {
                this.readonly = false;
            }
        },
    },
    computed: {
        grouplist() {
            if (this.grouplistdetail.length > 0) {
                let data = this.group(this.grouplistdetail, function (item) {
                    return item.req_groupid;
                });
                return data;
            }
        },
    },
    created() {
        this.getoption();
        // this.loguserdeptno();

        //this.RejectiReason();
    },
    mounted() {
        this.$bus.$on("imagecatch", (imgbase64) => {
            this.imagecatch(imgbase64);
        });
    },
    updated() {
        this.$nextTick(() => {
            // this.$refs.barcode.focus();
        });
        if (this.okFirstLoading) {
            this.$nextTick(() => {
                let currentrow = this.$refs.xTable1.getData(this.tempindex);
                if (currentrow) {
                    this.okFirstLoading = false;
                    this.$refs.xTable1.setCurrentRow(currentrow);
                    this.Exedetailretrieve(currentrow);
                }
            });
        }
    },
    methods: {
        formatFun({ row, cellValue }) {
            if (!!row.req_groupid) {
                let data = this.req_grouplist.filter((item) => item.data == row.req_groupid);
                if (data.length > 0) {
                    return data[0].display;
                } else {
                    return cellValue;
                }
            } else {
                return "未分类";
            }
        },
        group(list, f) {
            //分组函数
            const groups = {};
            list.forEach(function (re) {
                const group = f(re);
                groups[group] = groups[group] || [];
                groups[group].push(re);
            });
            return Object.keys(groups).map(function (group) {
                let groupLabel = group.split(","); //根据“，”切割成数组（可自定义）
                return {
                    req_groupid: groupLabel[0], //分单类别
                    samplecnt: groups[group].length, //数量
                    chkreqgroup: "0",
                };
            });
        },
        groupListChangeEvent({ row }) {
            this.groupListChangeEventFun(row);
        },
        chkreqgroupChange(row) {
            let data = this.grouplist.filter((item) => item.req_groupid != row.req_groupid);
            if (data.length > 0) {
                data.forEach((item) => {
                    item.chkreqgroup = "0";
                });
            }
        }, //分单类别弹窗右侧项目
        groupListChangeEventFun(row) {
            this.groupdetaillist = this.grouplistdetail.filter((item) => item.req_groupid == row.req_groupid);
        },
        diagPromise_click(t) {
            if (t == 0) {
                //点了取消按钮
                this.$refs.refdialogReqItem.Cancel();
            } else if (t == 1) {
                //点了确定按钮
                this.$refs.refdialogReqItem.Confirm();
            }
        }, //分单类别弹窗保存
        dialogReqItemSave() {
            let data = this.grouplist.filter((item) => item.chkreqgroup == "1");
            if (data.length > 0) {
                //有选中退回的分单类别
                return data[0].req_groupid;
                //this.dialogReqItem=false;
            } else {
                //所有分单类别都不退回
                return "";
            }
        },
        BarCodeSelect() {
            this.$refs.barcode.select();
        },
        HightlightPos(myValue) {
            if (myValue == "") {
                return false;
            }
            var myField = document.getElementById("barcodediv");
            if (myField.selectionStart || myField.selectionStart === 0) {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                this.$nextTick(() => {
                    myField.selectionStart = 0;
                    myField.selectionEnd = startPos + myValue.length;
                }); // 这句是重点, 圈起来
                myField.focus();
                myField.setSelectionRange(myField, myField.selectionStart, myField.selectionEnd);
            }
        },
        getoption() {
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "getoptions",
                    },
                })
                .then((res) => {
                    this.rejectcheckedsample = res.rejectcheckedsample;
                    this.rejectreqmusttell = res.rejectreqmusttell;
                    this.rejectreasonnoedit = res.rejectreasonnoedit;
                    this.reject_photo = res.reject_photo;
                    this.rejectdeletereport = res.rejectdeletereport;
                    this.ReqBackstyleid = res.ReqBackstyleid;
                    this.reject_popgroup = res.reject_popgroup;
                    this.req_grouplist = res.req_grouplist;
                    this.mustPhotoStr = res.mustPhotoStr;
                    this.RejectiReasonOption = res.RejectiReasonOption;
                    if (res.islogin) {
                        this.islogin = res.islogin;
                        this.loginbox();
                    } else {
                        this.loguserdeptno();
                    }
                    console.info("res.reject_photo==" + res.reject_photo);
                    if (res.reject_photo == "1") {
                        this.isshow = true;
                        this.LPicData = [];
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        querySearch(queryString, cb) {
            var restaurants = this.RejectiReasonOption;
            var results = queryString ? restaurants.filter(item=>item.label.toLowerCase().indexOf(queryString.toLowerCase()) > -1) : restaurants;
            cb(results);
        },
        loginbox() {
            this.$refs.barcode.select();
            this.$rm_Login({
                type: "用户登录验证",
                btn: {
                    confirmBtnText: "确定",
                    cancelBtnText: "取消",
                },
            })
                .then((res) => {
                    console.log("登录返回", res);
                    if (res.flag == "1") {
                        //登录成功
                        this.loginuserno = res.userid;
                        this.$refs.barcode.focus();
                        this.loguserdeptno();
                    } else {
                        //登录失败 关掉功能界面
                    }
                })
                .catch((e) => {
                    // 点击取消 关闭功能界面
                    this.closeTag();
                    console.log("error", e);
                });
        },
        closeTag() {
            this.$bus.$emit("closePathTags", "/LIS213");
        },
        selChange(scope, val){
            //赋值，改变拍照按钮的颜色
            scope.row.reject_reason = val.target.value;
        },
        deletepic(img){
            if(!!img){
                var index = this.LPicData.findIndex((m) => m == img);
                //删除
                this.LPicData.splice(index,1);
                let row = this.$refs.xTable1.getCurrentRow();
                row.reqrejectimage = '';
                for(var i = 0; i < this.LPicData.length; i++){
                    let itemImg = this.LPicData[i] + "$image_split$";
                    row.reqrejectimage += itemImg;
                }
            }
        },
        onPreview(imgList) {
            this.viewerList = [imgList];
            this.showViewer = true
        },
        closeViewer() {
            this.viewerList = [];
            this.showViewer = false
        },
        scanBarcode() {
            //如若条码号相同，不扫描
            if (this.chkenterflag.indexOf(this.txtbarcode) > -1) {
                this.HightlightPos(this.txtbarcode);
                return false;
            }
            this.chkenterflag = this.txtbarcode;
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "scanbarcode",
                        barcode: this.txtbarcode,
                    },
                })
                .then((res) => {
                    if (this.reject_popgroup == "1") {
                        //退回标本时开窗选择分单类别
                        if (!res.details) {
                            //没有返回明细(比如条码已退回)
                            if (!!res.masters) res.masters[0].havegroupid = "0";
                            this.rejectHandle(res); //不传分单类别
                        } else {
                            //返回明细开窗
                            this.grouplistdetail = res.details;
                            if (this.grouplist.length > 0) {
                                this.groupListChangeEventFun(this.grouplist[0]);
                                setTimeout(() => {
                                    this.$refs.refgrouplist.setCurrentRow(this.grouplist[0]);
                                }, 10);
                            }
                            this.$refs.refdialogReqItem
                                .ShowDialog()
                                .then(() => {
                                    let req_groupid = this.dialogReqItemSave();
                                    if (req_groupid != "") {
                                        //开窗后勾选了某个分单类别
                                        res.masters[0].req_groupid = req_groupid;
                                        if (!!res.masters) res.masters[0].havegroupid = "1"; //传分单类别
                                        this.rejectHandle(res);
                                    }
                                })
                                .catch(() => {});
                        }
                    } else {
                        if (!!res.masters) res.masters[0].havegroupid = "0"; //不传分单类别
                        this.rejectHandle(res);
                    }
                    this.okFirstLoading = true;

                    this.HightlightPos(this.txtbarcode);
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        rejectHandle(res) {
            switch (res.flag) {
                case 1:
                    this.txtbarcode = this.txtbarcode;
                    this.$refs.barcode.select();
                    if (res.masters.length > 0) {
                        res.masters.forEach((item) => {
                            item.reject_reason = this.txtrejReason;
                            item.rejectmsg = res.rejectmsg;
                            item.deletereport = "0";
                            item.chkflag = "1";
                            item.tellman = "";
                            this.master.splice(0, 0, item);
                            this.$nextTick(() => {
                                this.$refs.xTable1.setSelection(item, true);
                            });
                        });
                        //设置选中第一条
                        setTimeout(() => {
                            this.$refs.xTable1.setCurrentRow(this.master[0]);
                            this.detailretrieve({ row:this.master[0] });
                        }, 100);
                    }
                    break;
                case -1:
                    if (res.master) {
                        this.txtbarcode = res.masters.barcode + " 失败!" + res.msg;
                    } else {
                        this.txtbarcode = this.txtbarcode + " 失败!" + res.msg;
                    }
                    this.msg = res.msg;
                    this.flag = -1;
                    this.dialogshow();
                    break;
                case -99:
                    if(res.msglist.count == 1 && res.msglist[0].Item1 == "-99"){
                        if (this.rejectdeletereport == 0) {
                            //0提示是否退回
                            this.rejeopdialogflag = "提示是否退回|取消";
                        } else if (this.rejectdeletereport == 1) {
                            //1提示是否要删除报告信息
                            this.rejeopdialogflag = "删除并退回|仅退回|取消";
                        } else if (this.rejectdeletereport == 2) {
                            //2禁止退回标本,只有确定按钮
                            this.rejeopdialogflag = "禁止退回标本";
                        } else if (this.rejectdeletereport == 3) {
                            //3直接删除未审核的报告
                            this.rejeopdialogflag = "退回并删除未审核|取消";
                        } else {
                            //4修改未审核报告条码号
                            this.rejeopdialogflag = "退回并修改条码号|取消";
                        }
                        this.msg = res.msg.replace(/\n/g, "<br/>");
                        this.flag = -99;

                        if (res.masters.length > 0) {
                            res.masters.forEach((item) => {
                                item.rejectmsg = res.rejectmsg;
                                item.reject_reason = this.txtrejReason;
                            });
                            this.lastmaster = res.masters;
                        }
                        this.rejeopdialog = true;
                        this.dialogshow2();
                        break;
                    }
                    else{
                        if (res.masters.length > 0) {
                            res.masters.forEach((item) => {
                                item.rejectmsg = res.rejectmsg;
                                item.reject_reason = this.txtrejReason;
                            });
                            this.lastmaster = res.masters;
                        }
                        this.msglist = res.msglist;
                        this.resinfo = res;
                        this.showMsg(this.msglist,res);
                    }
            }
        },
        showMsg(mlist,res){
            console.info("mlist.count=="+mlist.length);
            if(mlist[0].Item1 == "-2" || mlist[0].Item1 == "-3"){
                this.showrejmsg = mlist[0].Item2.replace(/\n/g, "<br/>");
                this.rejeopshowdialog = true;
            }
            else{
                if (this.rejectdeletereport == 0) {
                            //0提示是否退回
                            this.rejeopdialogflag = "提示是否退回|取消";
                } else if (this.rejectdeletereport == 1) {
                    //1提示是否要删除报告信息
                    this.rejeopdialogflag = "删除并退回|仅退回|取消";
                } else if (this.rejectdeletereport == 2) {
                    //2禁止退回标本,只有确定按钮
                    this.rejeopdialogflag = "禁止退回标本";
                } else if (this.rejectdeletereport == 3) {
                    //3直接删除未审核的报告
                    this.rejeopdialogflag = "退回并删除未审核|取消";
                } else {
                    //4修改未审核报告条码号
                    this.rejeopdialogflag = "退回并修改条码号|取消";
                }
                this.msg = res.msg.replace(/\n/g, "<br/>");
                this.flag = -99;

                if (res.masters.length > 0) {
                    res.masters.forEach((item) => {
                        item.rejectmsg = res.rejectmsg;
                        item.reject_reason = this.txtrejReason;
                    });
                    this.lastmaster = res.masters;
                }
                this.rejeopdialog = true;
                this.dialogshow2();
            }
        },

        showdialogclose(flag){
            this.rejeopshowdialog = false;
            if(flag == "1"){
                if(this.msglist.length == "1"){
                    this.dialogclose(0);
                }
                else{
                    this.msglist.splice(0,1);
                    this.showMsg(this.msglist,this.resinfo);
                }
            }
            else{
                this.chkenterflag = "";
                this.showrejmsg = "";
                this.rejeopdialog = false;
            }
        },

        canceldialog(){
            this.chkenterflag = "";
            this.rejeopdialog = false;
        },

        dialogclose(parm) {
            if (this.lastmaster.length > 0) {
                this.lastmaster.forEach((item) => {
                    item.deletereport = parm;
                    item.chkflag = "1";
                    this.master.splice(0, 0, item);
                    this.txtbarcode = item.barcode; //+ " 成功！"
                });
            }
            this.$nextTick(() => {
                this.lastmaster.forEach((row) => {
                    this.$refs.xTable1.setSelection(row, true);
                });
            });
            //设置选中第一条
            setTimeout(() => {
                this.$refs.xTable1.setCurrentRow(this.master[0]);
                this.detailretrieve({ row:this.master[0] });
            }, 100);
            this.rejeopdialog = false;
            this.okFirstLoading = true;
            this.HightlightPos(this.txtbarcode);
        },
        dialogshow() {
            //-1弹窗
            setTimeout(() => {
                this.$refs.btnfocus2.$el.focus();
            }, 100);
            this.rejeoptips = true;
            this.isused = false;
            this.HightlightPos(this.txtbarcode);
        },
        dialogshow2() {
            //-99弹窗
            if (this.rejeopdialogflag == "提示是否退回|取消") {
                setTimeout(() => {
                    this.$refs.btnfocus5.$el.focus();
                }, 100);
            } else if (this.rejeopdialogflag == "删除并退回|仅退回|取消") {
                setTimeout(() => {
                    this.$refs.btnfocus3.$el.focus();
                }, 100);
            } else if (this.rejeopdialogflag == "禁止退回标本") {
                setTimeout(() => {
                    this.$refs.btnfocus8.$el.focus();
                }, 100);
            } else if (this.rejeopdialogflag == "退回并修改条码号|取消") {
                setTimeout(() => {
                    this.$refs.btnfocus2.$el.focus();
                }, 100);
            } else {
                //退回并删除未审核|取消
                setTimeout(() => {
                    this.$refs.btnfocus6.$el.focus();
                }, 100);
            }
            this.rejeopdialog = true;
        },
        dialogshow3() {
            //保存成功后消息弹窗
            setTimeout(() => {
                this.$refs.btnfocus9.$el.focus();
            }, 100);
            this.rejeopdialogRet = true;
            this.HightlightPos(this.txtbarcode);
        },
        detailretrieve({ row }) {
            this.LPicData = [];
            if (this.isshow) {
                if(!!row.reqrejectimage){
                    if(row.reqrejectimage.endsWith('$image_split$')){
                        //去掉结尾
                        row.reqrejectimage = row.reqrejectimage.substring(0, row.reqrejectimage.length - 13);
                    }
                    this.LPicData = row.reqrejectimage.split("$image_split$");
                }
            }
            this.Exedetailretrieve(row);
            this.HightlightPos(this.txtbarcode);
        },
        Exedetailretrieve(row) {
            let barcode = row.barcode;
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "getdetails",
                        barcode: barcode,
                    },
                })
                .then((res) => {
                    if (this.reject_popgroup == "1") {
                        this.detail = res.details.filter((item) => item.req_groupid == row.req_groupid);
                    } else {
                        this.detail = res.details;
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        btnSave() {
            this.isused = true;
            let rejectinfo = [];
            let err = "";
            let tabledata = this.$refs.xTable1.getSelectRecords();
            let allcnt = tabledata.length;
            if (allcnt == 0) {
                //未勾选时弹窗
                this.msg = "请先勾选需要退回的标本！";
                this.dialogshow();
                this.isused = false;
                return false;
            }
            try {
                //未选择退回原因弹窗提醒
                tabledata.forEach((item) => {
                    let temp = [];
                    if (item.reject_reason == "") {
                        err += "条码号：【" + item.barcode + "】，未选择退回原因,请选择后再保存！";
                    }
                    else {
                        if(this.mustPhotoStr.indexOf('\'' + item.reject_reason + '\'') > -1 && !item.reqrejectimage){
                            //必须拍照
                            err += "条码号：【" + item.barcode + "】，选择的退回原因必须拍照，请拍照后再保存！";
                        }
                        else {
                            temp.push(item.barcode);
                            temp.push(item.reject_reason);
                            temp.push(item.deletereport);
                            temp.push(item.description);
                            temp.push(item.tellman);
                            temp.push(item.rejectmsg);
                            temp.push(this.loginuserno);
                            temp.push(item.reqrejectimage);
                            if (item.havegroupid == 1) {
                                temp.push(item.req_groupid); //如果没有开窗选分单类别，就不传分单类别到后台
                            }
                            rejectinfo.push(temp);
                        }
                    }
                });
            } catch (e) {}
            if (err != "") {
                this.msg = err;
                this.dialogshow();
                this.isused = false;
                return false;
            }
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "rejectbarcodes",
                        rejectinfo: rejectinfo,
                    },
                })
                .then((res) => {
                    this.msglist = []; //获取失败信息列表
                    let faildcnt = 0;
                    if (res.faildBarcode.length > 0) {
                        res.faildBarcode.forEach((item) => {
                            let msg = item.Item1 + "," + item.Item2;
                            this.msglist.push(msg);
                            faildcnt++;
                        });
                    }

                    //页面处理
                    let data = this.$refs.xTable1.getSelectRecords();
                    this.$refs.xTable1.clearSelection();
                    if (res.faildBarcode.length == 0) {
                        //都成功
                        data.forEach((row) => {
                            this.$refs.xTable1.setSelection(row, false);
                            row.rejectmsg = "";
                            row.chkflag = "0"; //是否可勾选--不可勾选
                        });
                    } else {
                        //有失败
                        //循环失败的条码，成功的条码不让勾选，并且清空rejectmsg
                        data.forEach((row) => {
                            res.faildBarcode.forEach((item) => {
                                if (row.barcode != item.Item1) {
                                    //不在失败列表->成功
                                    this.$refs.xTable1.setSelection(row, false);
                                    row.rejectmsg = "";
                                    row.chkflag = "0"; //是否可勾选--不可勾选
                                } else {
                                    this.$refs.xTable1.setSelection(row, true);
                                    row.chkflag = "1"; //是否可勾选--可勾选
                                }
                            });
                        });
                    }
                    if (res.faildBarcode.length == 0) {
                        //成功弹窗
                        this.msg = "本次共退回标本" + allcnt + "条，退回成功" + (allcnt - faildcnt) + "条，退回失败" + faildcnt + "条！";
                        this.dialogshow();
                    } else {
                        //失败弹窗
                        this.dialogshow3();
                    }
                })
                .catch((e) => {
                    this.isused = false;
                    console.log("error", e);
                });
        },
        checkMethod({ row }) {
            if (row.chkflag == "1") {
                //退回条码可勾选
                return true;
            } else {
                return false;
            }
        },
        CellActive({ row, columnIndex }) {
            if (row.chkflag == "1") {
                //退回条码可勾选
                return true;
            } else {
                return false;
            }
        },
        btnPrint(e) {
            if (!this.ReqBackstyleid) {
                this.$alert("未获取到退回清单格式，请检查是否设置！");
                return false;
            }
            let dbtype = this.$ddldata.DbType;
            if (e.shiftKey) {
                 //调整
                let sql = "select top 1 1 as 条数,'1' as 序号,* from req_master_all_name";
                if(dbtype == "2"){
                    sql = "select  1 as 条数, '1' as 序号,* from req_master_all_name  limit 1";
                }
                else if(dbtype == "3"){
                    sql = "select 1 as 条数,'1' as 序号, req_master_all_name.*  from req_master_all_name where rownum = 1";
                }
                this.$pub.printlistbill(this, sql, "3", this.ReqBackstyleid, "退回清单样式", "");
            } else {
                //打印
                let barcode = "";
                let data = this.$refs.xTable1.tableData; //getSelectRecords();
                let barnum = 0;
                data.forEach((item) => {
                    if (barcode == "") {
                        barcode = item.barcode;
                    } else {
                        barcode = barcode + "','" + item.barcode;
                    }
                    barnum++;
                });
                let sql = "select '" + barnum + "' as 条数,row_number() over (order by 条码号) as 序号,* from req_master_all_name where 条码号 in ('" + barcode + "')";
                if(dbtype == "2"){
                    sql = "select '" + barnum + "' as 条数,@rownum:=@rownum+1 as 序号, req_master_all_name.* from (select @rownum:=0) r, req_master_all_name where req_master_all_name.条码号 in ('" + barcode + "')";
                }
                else if(dbtype == "3"){
                    sql = "select '" + barnum + "' as 条数,rownum as 序号,req_master_all_name.*  from req_master_all_name where req_master_all_name.条码号 in ('" + barcode + "')";
                }

                this.$pub.printlistbill(this, sql, "1", this.ReqBackstyleid, "退回清单样式", "");
                this.$confirm("打印完成，是否清楚标本退回列表？", "提示", {
                    confirmButtonText: "是",
                    cancelButtonText: "否",
                    type: "warning",
                })
                    .then(() => {
                        this.master = [];
                        this.detail = [];
                    })
                    .catch(() => {});
            }
        },
        btnClear() {
            this.txtbarcode = "";
            this.chkenterflag = "";
            this.master = [];
            this.lastmaster = [];
            this.detail = [];
            this.isused = false;
            this.LPicData = [];
        },
        loguserdeptno() {
            this.$tool
                .request({
                    url: "ucent/ddl",
                    method: "post",
                    data: {
                        action: "loguserdeptno",
                        userno: this.loginuserno,
                    },
                })
                .then((res) => {
                    if (res.deptno != "") {
                        this.exedeptname = res.deptname + "(" + res.deptno + ")";
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        EditCloseEvent({ row, column }) {
            if (column.property == "tellman") {
                this.$pub.getname("user", row.tellman).then((r) => {
                    row.tellman = r;
                });
            }
        },
        CellDBLClickEvent({ row, column }) {
            if (column.property == "tellman") {
                this.currentRow = row;
                this.dialogusersel = true;
            }
        },
        diagUserInfoChange(code, name, row) {
            this.currentRow.tellman = row.hidname;
            this.dialogusersel = false;
        },
        cameraEvent(row) {
            this.camerarowindex = this.master.indexOf(row);

            if (typeof jsObj != "undefined") {
                //jsObj.AsyncCall("入参");  js这边就这样调用
                var s = jsObj.AsyncCall("callexe:ImageCatch.exe");
            } else {
                this.$alert("请使用" + this.$pub.clientname + "打开系统", "错误", {
                    confirmButtonText: "确定",
                });
            }
        },
        imagecatch(imgbase64) {
            console.log("saveimage");
            var imagedata = "data:image/png;base64," + imgbase64;
            let row = this.master[this.camerarowindex];
            var imageS = imagedata + "$image_split$"
            row.reqrejectimage += imageS;
            this.LPicData.push(imagedata);
            this.$message.success("已拍摄完成！");
        },
        ImageUpload(imagedata) {},
    },
    beforeDestroy(){
        this.$bus.$off("imagecatch");
    }
};
</script>

<style scoped>
.table1style tr td {
    padding: 0px 2px 0px 5px;
}
.table1style .el-input--medium {
    /*  font-size: 18px;
    font-weight: 700;*/
}
::deep.popdialogstyle tr td div .el-input__inner {
    border: 1px solid rgba(255, 254, 254, 0) !important;
    background-color: rgba(255, 254, 254, 0) !important;
}

.top-deal {
    right: 5px;
    position: absolute;
    top: 20px;
    display: flex;
    align-items: center;
}

.autopart {
    top: 0px !important;
}
</style>
